<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="java.util.Vector,java.util.ArrayList,com.ejoysoft.wlanyz.business.Disturb,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@page import="com.ejoysoft.wlanyz.business.Proportion"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("20020"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>

<%
    //初始化
    Proportion  proportion=null;
    Proportion obj=new Proportion(globa);
    //查询条件
    String  strCity = ParamUtil.getString(request,"strCity","");
    String  strTown = ParamUtil.getString(request,"strTown","");
    String  strOneAc = ParamUtil.getString(request,"strOneAc","");
    String  strStartTime = ParamUtil.getString(request,"strStartTime","");
    String  strEndTime = ParamUtil.getString(request,"strEndTime","");
     // System.out.println(strCity+"--------------------"+strTown);
    if(!strStartTime.equals("")&&!strEndTime.equals("")){
	 if(strStartTime.compareTo(strEndTime)>0)
       {
          out.print("<script>alert('起始时间大于终止时间，请重新输入');window.history.back(-1);</script>");  	
        } 
	}
     //System.out.println("%%%%%%%%%%%%%%%"+strEndTime);
    
    
	String tWhere=" WHERE 1=1 and strcity = '"+strCity+"' and strtown= '"+strTown+"' ";

    if(!strOneAc.equals("")){
     tWhere += "  and strclassonehp LIKE '%"+strOneAc+"%' ";
    }
    
      
	//记录总数
	int intAllCount=obj.getCount2(tWhere);	
	//当前页
    int intCurPage=globa.getIntCurPage();
	//每页记录数
	// int intPageSize=globa.getIntPageSize();
    String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	 
     
	Vector<Proportion> vctObj=obj.list3(tWhere,intStartNum,intPageSize);
	
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	String where = " where strcity='"+strCity+"' and strtown = '"+strTown+"' ";
    ArrayList<String> oneacList = obj.getByName(where,"strclassonehp");
    
   
%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>测试结果比例报表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<link href="../common/css/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../js/jquery-1.4.1.min.js"></script>
<script src="../include/DatePicker/WdatePicker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
<!--
body {
	background-color: #f2f8ff;
}
.sel1{ width:160px;}
.STYLE1 {color: #FF0000}
.s6 a:link{ line-height:25px;height:25px; color:#2074b8;text-decoration:none}
.s6 a:hover{ line-height:25px;height:25px; color:#333333;text-decoration:none}
-->
</style>

<script type="text/javascript">
function showAc(){ 
  frm.action="results_oneac.jsp";
  frm.<%=com.ejoysoft.common.Constants.PAGE_SIZE_INDEX%>.value = "1";
  frm.submit();
 }
 
 
 function export_sbm(page){ 
  frm.action="proportion_export.jsp";
  document.getElementById("strCurPage").value = "<%=intCurPage%>";;
  document.getElementById("exportContent").value = page;
  frm.submit();
 }
 
 function toTwoAc(strOneAc,twoacnum){
 if(twoacnum!=0){
  frm.action = "results_twoac.jsp";
  frm.<%=com.ejoysoft.common.Constants.PAGE_SIZE_INDEX%>.value = "1";
  document.getElementById("strOneAc").value = strOneAc;
  frm.submit();}else{
  alert("该一级热点没有二级热点！");
  }
 }
 
  function toTown(city){
  frm.action = "results_town.jsp";
  frm.<%=com.ejoysoft.common.Constants.PAGE_SIZE_INDEX%>.value = "1";
  document.getElementById("strCity").value = city;
  document.getElementById("strTown").value = "";
  frm.submit();
 }
 

</script>
</head>

<body >
<form name="frm" METHOD=POST ACTION="results_oneac.jsp">
<input id="strCity" name="strCity" type="hidden" value="<%=strCity %>"/>
<input id="strTown" name="strTown" type="hidden" value="<%=strTown %>"/>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><img src="../images/ri_list.jpg" width="14" height="14" align="absbottom" />&nbsp;您现在所在的位置：<font color="#0e7cc9">任务管理</font> &gt; 测试完成比例报表</td>       
  </tr>
</table>
<table  width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  
  <tr>
    <td height="45" valign="middle" bgcolor="e1eef7">
      <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="left" width="40%" height="40">一级热点(<span class="STYLE1">*</span>)
          <select id="strOneAc" name="strOneAc" class="sel1" style="width:100px" >
          <option value="">--请选择--</option>
			 <% for (int j = 0; j <  oneacList.size(); j++) {
					String oneac = oneacList.get(j);
					String selected = "";
					if(oneac !=null){
					if(strOneAc!= null && strOneAc.equals(oneac))
						selected = "selected='selected'";
				%>
				<option value="<%=oneac%>" <%=selected%>>
					<%=oneac%>
				</option>
				<%
				}
				}
				%>
          </select></td>
          
           <td align="right" width="50%" >起止时间(<span class="STYLE1">*</span>)
	          <input id="strStartTime" name="strStartTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" class="input_box" value="<%=strStartTime %>"style="width:100"/>-
	          <input id="strEndTime"  name="strEndTime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" class="input_box" value="<%=strEndTime %>"style="width:100"/>
          </td>
        <td width="%">&nbsp;</td>
        <td><img src="../images/search.jpg" width="58" height="28" onclick="showAc()" style="cursor:hand"/></td>
        </tr>
      </table></td>
  </tr>
</table>
<br>
<table  id="tb" width="97%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr role="head">
    <td sort="true" width="10%" class="listtit">地市</td>
    <td sort="true" width="10%" class="listtit">区县</td>
    <td sort="true" width="10%" class="listtit">一级热点</td> 
    <td sort="true" width="10%" class="listtit">二级热点数量</td> 
    <td sort="true" width="10%" class="listtit">AP数量</td>
    <td sort="true" width="10%" class="listtit">已测AP数</td>
    <td sort="true" width="10%" class="listtit">已测AP百分比</td>
    <td sort="true" width="10%" class="listtit">上卷</td>
    <td width="10%" class="listtit">下钻</td>
  </tr>
        <%
        double proportion1 = 0;
        int num = 0;
            for (int i = 0;i < vctObj.size(); i++) {
            	Proportion obj1 = vctObj.get(i); 
            	num = obj1.getTestAp(strCity,strTown,obj1.getStrOneAc(),strStartTime,strEndTime);
            	 if(obj1.getAp(strCity,strTown,obj1.getStrOneAc())!=0){
            	 proportion1 =  num*100/obj1.getAp(strCity,strTown,obj1.getStrOneAc());
            	 }else{
            	 proportion1 = 0;
            	 }
        %>
  <tr>
     <td align="center" class="listd1" style="border-left:1px solid #dddddd;"><%=strCity %></td>
    <td align="center" class="listdrd"><%=strTown %></a></td>
    <td align="center" class="listd1"><%=obj1.getStrOneAc() %></td>
    <td align="center" class="listd1"><%=obj1.getTwoAcNum() %></td>
    <td align="center" class="listd1"><%=obj1.getAp(strCity,strTown,obj1.getStrOneAc()) %></td>
    <td align="center" class="listd1"><%=num %></td>
    <td align="center" class="listd1"><%=proportion1 %>%</td>
    <td align="center" class="listd1"><a href="#" onclick="toTown('<%=strCity %>')"><img src="../images/cx22.jpg" height="20" border="0" /></a></td>
    <td align="center" class="listdrd" style="border-right:1px solid #dddddd;"><a href="#" onclick="toTwoAc('<%=obj1.getStrOneAc()%>','<%=obj1.getTwoAcNum() %>')"><img src="../images/1-11112R01455.png" height="20" border="0" /></a></td>
  </tr>
         <%
           }//for 
         %>
  
</table>
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="61%" height="50" valign="bottom"><!--<img src="../images/pldel.jpg" width="83" height="27" align="middle" />--> &nbsp;&nbsp;页面记录数
      <select name="strPageSize" id="strPageSize" style="width:52px;" onchange="showAc()">
		<% 
		 String sltOpt[] = {"10","20","30","50","70","100","所有"};
		 for(int i=0; i < sltOpt.length;i++){
		 	String selected = "";
		    if(sltOpt[i].equals(strPageSize))
		      selected="selected='selected'";
		 %>
		 <option value="<%=sltOpt[i] %>" <%=selected %>><%=sltOpt[i] %></option>
   		<%
   		 }
   		 %>
   		 </select>
      <img src="../images/dc.jpg" width="92" height="27" align="middle" onclick="export_sbm('currentPage')" style="cursor:hand"/> 
      <img src="../images/dcall.jpg" width="82" height="27" align="middle" onclick="export_sbm('allPage')" style="cursor:hand"/></td>
    <td>  <input id="exportFlag" name="exportFlag" type="hidden" value="results_oneac"/>
       		 <input id="strCurPage" name="strCurPage" type="hidden" value=""/>
			<input id="exportContent" name="exportContent" type="hidden" value=""/></td>
    <td width="39%" align="right" valign="bottom"><!--<table width="310" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="40"><img src="../images/up.jpg" width="40" height="30" /></td>
        <td width="221" align="center" background="../images/page_bg.jpg" class="page"><a href="#">1</a>&nbsp; <a href="#">2</a>&nbsp; <a href="#">3</a>&nbsp; <a href="#"><span class="sel">4</span></a>&nbsp; <a href="#">5</a> &nbsp;<a href="#">6</a> &nbsp;<a href="#">7</a>&nbsp; <a href="#">8 </a>&nbsp;<a href="#">9</a>&nbsp;...&nbsp;<a href="#">13</a> </td>
        <td width="39"><img src="../images/down.jpg" width="39" height="30" /></td>
      </tr>
    </table>-->
    <!-- 翻页开始 -->  
     	<%@ include file="../include/jsp/cpage.jsp"%>
       	<!-- 翻页结束 --> </td>
    
  </tr>
</table>
</body>
</html>

<%@ include file="../include/jsp/footer.jsp"%>
